<template>
  <div>
    <div id="com" style="width:80%;margin: 20px auto;height:400px;"></div>
  </div>
</template>
<script>
export default {
  props: ['date', 'qian', 'hou', 's'],
  mounted () {
    this.makeLine()
  },
  watch: {
    date (newVal) {
      console.log(newVal)
      this.makeLine()
    }
  },
  methods: {
    makeLine () {
      var mycharts = this.$echarts.init(document.getElementById('com'))
      var option = {
        title: {
          text: '每天课程新增统计'
        },
        tooltip: {
          trigger: 'axis'
        },
        legend: {
          data: this.date
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        toolbox: {
          feature: {
            saveAsImage: {}
          }
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: this.date
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            name: '前端',
            type: 'line',
            stack: 'Total',
            data: this.qian
          },
          {
            name: '后端',
            type: 'line',
            stack: 'Total',
            data: this.hou
          },
          {
            name: '视觉设计',
            type: 'line',
            stack: 'Total',
            data: this.s
          }
        ]
      }
      mycharts.setOption(option)
    }
  }
}
</script>
<style lang="less"></style>
